package com.zx.viewlearn.views.pullableview;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 * Author     Sdz
 * Email      946616236@qq.com
 * Time       2016/12/13 0013
 * Function   RecyclerView间距
 */

public class RecyclerViewSpacesItemDecoration extends RecyclerView.ItemDecoration {
    private int space;

    public RecyclerViewSpacesItemDecoration(int space) {
        this.space = space;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view,
                               RecyclerView parent, RecyclerView.State state) {
        outRect.left = space;
        outRect.right = space;
        outRect.bottom = space;

        // Add top margin only for the first item to avoid double space between items
//        if (parent.getChildPosition(view) == 0)
//            outRect.top = space;
    }
}
